package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo20Submit {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()

    /**
      * 将代码提交到集群运行，不需要指定master
      *
      */
    //conf.setMaster("local")
    conf.setAppName("Demo20Submit")


    val sc = new SparkContext(conf)


    val listRDD: RDD[Int] = sc.makeRDD(List(1, 2, 3, 4, 5, 6, 7, 8, 9))

    val sum: Double = listRDD.sum()

    println(s"sum is:$sum")

    /**
      * 将代码提交到集群运行
      * 1、将项目打包上传到集群
      * 2、spark-submit --class com.shujia.spark.Demo20Submit --master spark://master:7077 spark-1.0.jar
      * 需要再jar所在的位置提交任务
      */
  }

}
